test-sysroot: Use GSystem to spawn subprocess
authorColin Walters <walters@verbum.org>
Wed, 19 Mar 2014 13:13:28 +0000 (09:13 -0400)
committerColin Walters <walters@verbum.org>
Wed, 19 Mar 2014 13:15:38 +0000 (09:15 -0400)
I was getting a weird hang in the installed tests with the shell as a
zombie process, not reaped by the parent, which was just stuck in
select() on the output pipes.  The thing is we don't actually want to
capture stdout/stderr, we just want to inherit.

GSystem.Subprocess makes that possible, so let's just use it now that
it's a proper installed library.

tests/test-sysroot.js

index cfc45dbe0626c48a135e7dae15c12c345f5eb326..671eaac3247d623efc44d1cd7daf4bd53ea32b70 100644 (file)
@@ -20,6 +20,7 @@
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 
+const GSystem = imports.gi.GSystem;
 const OSTree = imports.gi.OSTree;
 
 function assertEquals(a, b) {
@@ -35,11 +36,13 @@ function assertNotEquals(a, b) {
 function libtestExec(shellCode) {
     let testdatadir = GLib.getenv("TESTDATADIR");
     let libtestPath = GLib.build_filenamev([testdatadir, 'libtest.sh'])
-    let cmdline = 'bash -c ' + GLib.shell_quote('. ' + GLib.shell_quote(libtestPath) + '; ' + shellCode);
-    print("shellcode=" +cmdline);
-    let [,stdout,stderr,estatus] = GLib.spawn_command_line_sync(cmdline);
-    print(stderr);
-    GLib.spawn_check_exit_status(estatus);
+    let proc = GSystem.Subprocess.new_simple_argv(['bash', '-c',
+                                                  '. ' + GLib.shell_quote(libtestPath) + '; ' + shellCode],
+                                                 GSystem.SubprocessStreamDisposition.INHERIT,
+                                                 GSystem.SubprocessStreamDisposition.INHERIT,
+                                                 null);
+    proc.init(null);
+    proc.wait_sync_check(null);
 }
 
 libtestExec('setup_os_repository archive-z2 syslinux');